package com.uduemc.biso.module.basic.service.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.uduemc.biso.core.extities.center.AuthorizeModel;
import com.uduemc.biso.module.basic.service.mapper.AuthorizeModelMapper;
import com.uduemc.biso.module.basic.service.service.AuthorizeModelService;

import tk.mybatis.mapper.entity.Example;

@Service
public class AuthorizeModelServiceImpl implements AuthorizeModelService {

	@Autowired
	private AuthorizeModelMapper authorizeModelMapper;

	@Override
	public AuthorizeModel insert(AuthorizeModel authorizeModel) {
		authorizeModelMapper.insert(authorizeModel);
		return findOne(authorizeModel.getId());
	}

	@Override
	public AuthorizeModel insertSelective(AuthorizeModel authorizeModel) {
		authorizeModelMapper.insertSelective(authorizeModel);
		return findOne(authorizeModel.getId());
	}

	@Override
	public AuthorizeModel updateById(AuthorizeModel authorizeModel) {
		authorizeModelMapper.updateByPrimaryKey(authorizeModel);
		return findOne(authorizeModel.getId());
	}

	@Override
	public AuthorizeModel updateByIdSelective(AuthorizeModel authorizeModel) {
		authorizeModelMapper.updateByPrimaryKeySelective(authorizeModel);
		return findOne(authorizeModel.getId());
	}

	@Override
	public AuthorizeModel findOne(long id) {
		return authorizeModelMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<AuthorizeModel> findAll() {
		Example example = new Example(AuthorizeModel.class);
		example.setOrderByClause("`order_num` DESC, `id` DESC");
		return authorizeModelMapper.selectByExample(example);
	}

}
